<?php
$this->pageTitle = Yii::app()->name . ' - ' . AdmincpModule::t("Profile");
?>
<div id="content-header">
    <?php
    $this->widget('bootstrap.widgets.TbBreadcrumbs', array(
        'links' => array('Users' => array('/admincp/profile'), 'Cập nhật'),
        'htmlOptions' => array('id' => 'breadcrumb')
    ));
    ?>
</div>
<div class="row-fluid">
    <div class="span12">
        <div class="widget-box">
                  <div class="widget-content nopadding">
                <div class="widget-container">
                    <?php
                    $form = $this->beginWidget('UActiveForm', array(
                        'id' => 'profile-form',
                        'enableAjaxValidation' => true,
                        'htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'form-horizontal'),
                    ));
                    ?>
                    <?php // echo $form->errorSummary(array($model, $profile)); ?>

                    <?php
                    $profileFields = $profile->getFields();
                    if ($profileFields) {
                        foreach ($profileFields as $field) {
                            ?>
                            <div class="control-group">
                                <?php
                                echo $form->labelEx($profile, $field->varname, array('class' => 'control-label'));
                                echo '<div class="controls">';
                                if ($field->widgetEdit($profile)) {
                                    echo $field->widgetEdit($profile);
                                } elseif ($field->range) {
                                    echo $form->dropDownList($profile, $field->varname, Profile::range($field->range));
                                } elseif ($field->field_type == "TEXT") {
                                    echo $form->textArea($profile, $field->varname, array('control-groups' => 6, 'cols' => 50));
                                } else {
                                    echo $form->textField($profile, $field->varname, array('size' => 60, 'maxlength' => (($field->field_size) ? $field->field_size : 255)));
                                }
                                echo $form->error($profile, $field->varname) . '</div>';
                                ?>
                            </div>	
                            <?php
                        }
                    }
                    ?>
                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'username', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textField($model, 'username', array('size' => 20, 'maxlength' => 20)); ?>
                            <?php echo $form->error($model, 'username'); ?>
                        </div>
                    </div>

                    <div class="control-group">
                        <?php echo $form->labelEx($model, 'email', array('class' => 'control-label')); ?>
                        <div class="controls">
                            <?php echo $form->textField($model, 'email', array('size' => 60, 'maxlength' => 128)); ?>
                            <?php echo $form->error($model, 'email'); ?>
                        </div>
                    </div>

                    <div class="form-actions">
                        <?php echo CHtml::submitButton($model->isNewRecord ? AdmincpModule::t('Create') : AdmincpModule::t('Save'), array('class' => 'pull-right btn btn-success')); ?>
                    </div>

                    <?php $this->endWidget(); ?>

                </div><!-- form -->
            </div>
        </div>
    </div>
</div>
